<?php
require("Sajax.php");
include ('common/connection.php');
$queryUser="SELECT max(id) as id FROM `users`";
$resultUser=mysql_db_query($db_name,$queryUser);
$rsUser=mysql_fetch_array($resultUser);

$group=$_REQUEST['group'];
$batch=$_REQUEST['batch'];
$gender=$_REQUEST['gender'];
$full_name=$_REQUEST['full_name'];
$nick_name=$_REQUEST['nick_name'];
$cell_phone=$_REQUEST['cell_phone'];
$cell_phone1=$_REQUEST['cell_phone1'];
$email=$_REQUEST['email'];
$address=$_REQUEST['address'];
$amount=$_REQUEST['amount'];
$spouse=$_REQUEST['spouse'];
function generateRandomNumber($ranLength)
{
	$random_id_length = $ranLength; 
	$rnd_id = uniqid(rand(),1); 
	//$rnd_id = md5(uniqid(rand(), true));
	//$rnd_id = strip_tags(stripslashes($rnd_id)); 
	//$rnd_id = str_replace(".","",$rnd_id); 
	$rnd_id = strrev(str_replace("/","",$rnd_id)); 
	$rnd_id = substr($rnd_id,0,$random_id_length);	
	return $rnd_id;
}
$GenerateOrderId=generateRandomNumber("4");
# Define the email validation function
function validate($email) {
    if (preg_match(
    '/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/',
    $email)) {
        return 'Valid';
    } else {
        return 'Invalid';
    }
}

# Initialize Sajax
sajax_init();
# Export the server-side function to Sajax
sajax_export('validate');
# Handle client request
sajax_handle_client_request();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>::.Already Registered.::</title>
<link rel="stylesheet" href="style/style.css" type="text/css" /> 
<script language="javascript" src="jscript/digit.js"></script>

<script language="javascript">
function validation()
{
var valid;

if (document.regis.group.value == "")
		{
			alert("Please Select Group.");
			document.regis.group.focus();
			valid = 0;
			return false;
		}
if (document.regis.batch.value == "")
		{
			alert("Please Select Batch.");
			document.regis.batch.focus();
			valid = 0;
			return false;
		}
if (document.regis.gender.value == "")
		{
			alert("Please Select Gender.");
			document.regis.gender.focus();
			valid = 0;
			return false;
		}
if (document.regis.full_name.value == "")
		{
			alert("Please Enter Full Name.");
			document.regis.full_name.focus();
			valid = 0;
			return false;
		}
if (document.regis.nick_name.value == "")
		{
			alert("Please Enter Nick Name.");
			document.regis.nick_name.focus();
			valid = 0;
			return false;
		}
if (document.regis.cell_phone.value == "")
		{
			alert("Please Enter Cell Phone.");
			document.regis.cell_phone.focus();
			valid = 0;
			return false;
		}
if (document.regis.email.value == "")
		{
			alert("Please Enter Your Email.");
			document.regis.email.focus();
			valid = 0;
			return (false);
		}
		else
		{
			var posOfAddress = document.regis.email.value.indexOf('@');
			var posOfDot = document.regis.email.value.indexOf('.');

			if(posOfAddress>0){
			}
			else
			{
				alert('The Email Address You Entered Is Not Valid. Please Enter The Valid One');
				document.regis.email.focus();
				document.regis.email.select();
				return false;
			}
			if(posOfDot>0){
			}
			else
			{
				alert('The Email Address You Entered Is Not Valid. Please Enter The Valid One');
				document.regis.email.focus();
				document.regis.email.select();
				return false;
			}
		 	
		}

if (document.regis.conemail.value == "")
		{
			alert("Please Enter Your Confirm Email.");
			document.regis.conemail.focus();
			valid = 0;
			return (false);
		}
		else
		{
			var posOfAddress = document.regis.conemail.value.indexOf('@');
			var posOfDot = document.regis.conemail.value.indexOf('.');

			if(posOfAddress>0){
			}
			else
			{
				alert('The Email Address You Entered Is Not Valid. Please Enter The Valid One');
				document.regis.conemail.focus();
				document.regis.conemail.select();
				return false;
			}
			if(posOfDot>0){
			}
			else
			{
				alert('The Email Address You Entered Is Not Valid. Please Enter The Valid One');
				document.regis.conemail.focus();
				document.regis.conemail.select();
				return false;
			}
		 	
		}
if (document.regis.conemail.value!=document.regis.email.value)
		{
			alert("Please make sure both email address are same.");
			document.regis.conemail.focus();
			valid = 0;
			return false;
		}
if (document.regis.address.value == "")
		{
			alert("Please Enter Postal Address.");
			document.regis.address.focus();
			valid = 0;
			return false;
		}
var nRadio = regis['amount'];
		if (!nRadio[0].checked && !nRadio[1].checked &&!nRadio[2].checked)
			{
			 alert('You Must Choose Your Registration Option');
			 return false;
			}
var nRadioo = regis['spouse'];
		if (!nRadioo[0].checked && !nRadioo[1].checked)
			{
			 alert('You Must Choose Are You Bringing Your Spouse Along ? Yes Or Not.');
			 return false;
			}
if (document.regis.id_no.value == "")
		{
			alert("Please Enter The Letter Shown Above in The Folling Box.");
			document.regis.id_no.focus();
			valid = 0;
			return false;
		}
if (document.regis.uid.value!=document.regis.id_no.value)
		{
			alert("Please make sure both your Text and Shown Above text are same.");
			document.regis.id_no.focus();
			valid = 0;
			return false;
		}

}
<?php
        # Sajax toolkit generated javascript code
        sajax_show_javascript();
    ?>
    // Sends the email input to the server-side function
    // and throws the return value to showValidation.
    function js_validate(email) {
        x_validate(email, showValidation);
    }
    // Prints the return value on the screen.
    // Changes the container's font color to green
    // if the return value is "Valid" and
    // to red if not.
    function showValidation(html) {
        var element = document.getElementById('validation');
        element.innerHTML = html;
        if (html=='Valid')
            element.style.color = 'green';
        else
            element.style.color = 'red';
    }
window.onerror = null;
 var bName = navigator.appName;
 var bVer = parseInt(navigator.appVersion);
 var NS4 = (bName == "Netscape" && bVer >= 4);
 var IE4 = (bName == "Microsoft Internet Explorer" 
 && bVer >= 4);
 var NS3 = (bName == "Netscape" && bVer < 4);
 var IE3 = (bName == "Microsoft Internet Explorer" 
 && bVer < 4);
 var blink_speed=100;
 var i=0;
 
if (NS4 || IE4) {
 if (navigator.appName == "Netscape") {
 layerStyleRef="layer.";
 layerRef="document.layers";
 styleSwitch="";
 }else{
 layerStyleRef="layer.style.";
 layerRef="document.all";
 styleSwitch=".style";
 }
}

function Blink(layerName){
 if (NS4 || IE4) { 
 if(i%2==0)
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="visible"');
 }
 else
 {
 eval(layerRef+'["'+layerName+'"]'+
 styleSwitch+'.visibility="hidden"');
 }
 } 
 if(i<1)
 {
 i++;
 } 
 else
 {
 i--
 }
 setTimeout("Blink('"+layerName+"')",blink_speed);
}
function selectgroup()
{
	document.regis.action="index.php";
	document.regis.submit();	
}
</script>
</head>

<body topmargin="0" centermargin="0">
</td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2"></td>
  </tr>
</table></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2" align="center" class="remark">
<script language="javascript">Blink('prem_hint');</script></td>
      </tr>
      <tr>
        <td width="402" height="30" align="center"><table width="110" border="0">
        <tr>
        	<td>
</td>
        </tr>
    </table></td>
        <td width="402" align="center"><table width="110" border="0">
        <tr>
        	<td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
  <tr>
    <td align="center" class="formhead"><font size="5"><?php $origi=$rsUser['id']; echo $total=($origi);?></font></td>
  </tr>
  <td align="center" class="commenttext">
  Already Registered  </td>
</table>
</td>
        </tr>
    </table></td>
      </tr>
      <tr>
        <td colspan="2"></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2"></td>
              </tr>
              
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2"></td>
              </tr>
              <tr>
                <td align="center" class="commenttext">&nbsp;</td>
              </tr>
              <tr>
                <td align="center"></td>
                    </tr>
                  
                  <tr>
                    <td colspan="2" align="center">&nbsp;</td>
                    </tr>
                  </table></td>
              </tr>
              
            </table></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table>
    </form>
    </td>
  </tr>
</table>
</body>
</html>
